package com.wmyg.scanninggun.bean;

import com.wmyg.scanninggun.message.BillRequest;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 工单基本模型
 * @author wong
 */
@Data
@ToString
@AllArgsConstructor
public class Bill {

    /**
     * 工单号
     */
    private int billId;

    /**
     * 工人ID号
     */
    private int operator;

    /**
     * 设备号
     */
    private String deviceId;

    /**
     * 箱号
     */
    private String caseId;

    private Date creatime;

    private int state;

    private int factoryId;

    private String factoryName;

    private String[] boxes;

    public Bill(BillRequest billRequest) {
        this.operator = billRequest.getOperator();
        this.deviceId = billRequest.getDeviceId();
        this.caseId = billRequest.getCaseId();
        try {
            this.creatime = new SimpleDateFormat("yyyyMMddHHmmssSSS").parse(billRequest.getCreatime());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        this.boxes = billRequest.getBoxes();
    }

    public Bill() {}

}
